home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Tool Chest / !Interfaces / Universal Interfaces 2.0a1 / PInterfaces / ADSP.p next >
Encoding:
Text File  |  1994-07-21  |  8.7 KB  |  239 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        ADSP.p
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a1.1  ETO #15, MPW prerelease.  Sunday, July 17, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. }
  16.  
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT ADSP;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __ADSP__}
  27. {$SETC __ADSP__ := 1}
  28.  
  29. {$I+}
  30. {$SETC ADSPIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33.  
  34. {$IFC UNDEFINED __ERRORS__}
  35. {$I Errors.p}
  36. {$ENDC}
  37. {    ConditionalMacros.p                                            }
  38.  
  39. {$IFC UNDEFINED __APPLETALK__}
  40. {$I AppleTalk.p}
  41. {$ENDC}
  42. {    Types.p                                                        }
  43. {    OSUtils.p                                                    }
  44. {        MixedMode.p                                                }
  45.  
  46. {$PUSH}
  47. {$ALIGN MAC68K}
  48. {$LibExport+}
  49.  
  50. CONST
  51.     dspInit                        = 255;                            { create a new connection end }
  52.     dspRemove                    = 254;                            { remove a connection end }
  53.     dspOpen                        = 253;                            { open a connection }
  54.     dspClose                    = 252;                            { close a connection }
  55.     dspCLInit                    = 251;                            { create a connection listener }
  56.     dspCLRemove                    = 250;                            { remove a connection listener }
  57.     dspCLListen                    = 249;                            { post a listener request }
  58.     dspCLDeny                    = 248;                            { deny an open connection request }
  59.     dspStatus                    = 247;                            { get status of connection end }
  60.     dspRead                        = 246;                            { read data from the connection }
  61.     dspWrite                    = 245;                            { write data on the connection }
  62.     dspAttention                = 244;                            { send an attention message }
  63.  
  64.     dspOptions                    = 243;                            { set connection end options }
  65.     dspReset                    = 242;                            { forward reset the connection }
  66.     dspNewCID                    = 241;                            { generate a cid for a connection end }
  67. { connection opening modes }
  68.     ocRequest                    = 1;                            { request a connection with remote }
  69.     ocPassive                    = 2;                            { wait for a connection request from remote }
  70.     ocAccept                    = 3;                            { accept request as delivered by listener }
  71.     ocEstablish                    = 4;                            { consider connection to be open }
  72. { connection end states }
  73.     sListening                    = 1;                            { for connection listeners }
  74.     sPassive                    = 2;                            { waiting for a connection request from remote }
  75.     sOpening                    = 3;                            { requesting a connection with remote }
  76.     sOpen                        = 4;                            { connection is open }
  77.     sClosing                    = 5;                            { connection is being torn down }
  78.     sClosed                        = 6;                            { connection end state is closed }
  79. { client event flags }
  80.     eClosed                        = $80;                            { received connection closed advice }
  81.     eTearDown                    = $40;                            { connection closed due to broken connection }
  82.     eAttention                    = $20;                            { received attention message }
  83.     eFwdReset                    = $10;                            { received forward reset advice }
  84. { miscellaneous constants }
  85.     attnBufSize                    = 570;                            { size of client attention buffer }
  86.     minDSPQueueSize                = 100;                            { Minimum size of receive or send Queue }
  87.  
  88. { connection control block }
  89.  
  90. TYPE
  91.     TRCCB = PACKED RECORD
  92.         ccbLink:                ^TRCCB;                                    { link to next ccb }
  93.         refNum:                    UInt16;                                    { user reference number }
  94.         state:                    UInt16;                                    { state of the connection end }
  95.         userFlags:                UInt8;                                    { flags for unsolicited connection events }
  96.         localSocket:            UInt8;                                    { socket number of this connection end }
  97.         remoteAddress:            AddrBlock;                                { internet address of remote end }
  98.         attnCode:                UInt16;                                    { attention code received }
  99.         attnSize:                UInt16;                                    { size of received attention data }
  100.         attnPtr:                Ptr;                                    { ptr to received attention data }
  101.         reserved:                PACKED ARRAY [0..219] OF UInt8;            { for adsp internal use }
  102.     END;
  103.     TPCCB = ^TRCCB;
  104.  
  105.     DSPPBPtr = ^DSPParamBlock;
  106.  
  107.     {
  108.         ADSPConnectionEventProcPtr uses register based parameters on the 68k and cannot
  109.         be written in or called from a high-level language without the help of
  110.         mixed mode or assembly glue.
  111.  
  112.         In:
  113.          => sourceCCB       A1.L
  114.     }
  115.     ADSPConnectionEventProcPtr = ProcPtr;  { PROCEDURE ADSPConnectionEvent(sourceCCB: TPCCB); }
  116.     {
  117.         ADSPCompletionProcPtr uses register based parameters on the 68k and cannot
  118.         be written in or called from a high-level language without the help of
  119.         mixed mode or assembly glue.
  120.  
  121.         In:
  122.          => thePBPtr        A0.L
  123.     }
  124.     ADSPCompletionProcPtr = ProcPtr;  { PROCEDURE ADSPCompletion(thePBPtr: DSPPBPtr); }
  125.     ADSPConnectionEventUPP = UniversalProcPtr;
  126.     ADSPCompletionUPP = UniversalProcPtr;
  127.  
  128.     DSPParamBlock = PACKED RECORD
  129.         qLink:                    ^QElem;
  130.         qType:                    INTEGER;
  131.         ioTrap:                    INTEGER;
  132.         ioCmdAddr:                Ptr;
  133.         ioCompletion:            ADSPCompletionUPP;
  134.         ioResult:                OSErr;
  135.         ioNamePtr:                StringPtr;
  136.         ioVRefNum:                INTEGER;
  137.         ioCRefNum:                INTEGER;                                { adsp driver refNum }
  138.         csCode:                    INTEGER;                                { adsp driver control code }
  139.         qStatus:                LONGINT;                                { adsp internal use }
  140.         ccbRefNum:                INTEGER;
  141.         CASE INTEGER OF
  142.         0: (
  143.             ccbPtr:                        TPCCB;                                { pointer to connection control block }
  144.             userRoutine:                ADSPConnectionEventUPP;                { client routine to call on event }
  145.             sendQSize:                    UInt16;                                { size of send queue (0..64K bytes) }
  146.             sendQueue:                    Ptr;                                { client passed send queue buffer }
  147.             recvQSize:                    UInt16;                                { size of receive queue (0..64K bytes) }
  148.             recvQueue:                    Ptr;                                { client passed receive queue buffer }
  149.             attnPtr:                    Ptr;                                { client passed receive attention buffer }
  150.             localSocket:                UInt8;                                { local socket number }
  151.             filler1:                    UInt8;                                { filler for proper byte alignment }
  152.            );
  153.         1: (
  154.             localCID:                    UInt16;                                { local connection id }
  155.             remoteCID:                    UInt16;                                { remote connection id }
  156.             remoteAddress:                AddrBlock;                            { address of remote end }
  157.             filterAddress:                AddrBlock;                            { address filter }
  158.             sendSeq:                    UInt32;                                { local send sequence number }
  159.             sendWindow:                    UInt16;                                { send window size }
  160.             recvSeq:                    UInt32;                                { receive sequence number }
  161.             attnSendSeq:                UInt32;                                { attention send sequence number }
  162.             attnRecvSeq:                UInt32;                                { attention receive sequence number }
  163.             ocMode:                        UInt8;                                { open connection mode }
  164.             ocInterval:                    UInt8;                                { open connection request retry interval }
  165.             ocMaximum:                    UInt8;                                { open connection request retry maximum }
  166.             filler2:                    UInt8;                                { filler for proper byte alignment }
  167.            );
  168.         2: (
  169.             abort:                        UInt8;                                { abort connection immediately if non-zero }
  170.             filler3:                    UInt8;                                { filler for proper byte alignment }
  171.            );
  172.         3: (
  173.             reqCount:                    UInt16;                                { requested number of bytes }
  174.             actCount:                    UInt16;                                { actual number of bytes }
  175.             dataPtr:                    Ptr;                                { pointer to data buffer }
  176.             eom:                        UInt8;                                { indicates logical end of message }
  177.             flush:                        UInt8;                                { send data now }
  178.            );
  179.         4: (
  180.             attnCode:                    UInt16;                                { client attention code }
  181.             attnSize:                    UInt16;                                { size of attention data }
  182.             attnData:                    Ptr;                                { pointer to attention data }
  183.             attnInterval:                UInt8;                                { retransmit timer in 10-tick intervals }
  184.             filler4:                    UInt8;                                { filler for proper byte alignment }
  185.            );
  186.         5: (
  187.             statusCCB:                    TPCCB;                                { pointer to ccb }
  188.             sendQPending:                UInt16;                                { pending bytes in send queue }
  189.             sendQFree:                    UInt16;                                { available buffer space in send queue }
  190.             recvQPending:                UInt16;                                { pending bytes in receive queue }
  191.             recvQFree:                    UInt16;                                { available buffer space in receive queue }
  192.            );
  193.         6: (
  194.             sendBlocking:                UInt16;                                { quantum for data packets }
  195.             sendTimer:                    UInt8;                                { send timer in 10-tick intervals }
  196.             rtmtTimer:                    UInt8;                                { retransmit timer in 10-tick intervals }
  197.             badSeqMax:                    UInt8;                                { threshold for sending retransmit advice }
  198.             useCheckSum:                UInt8;                                { use ddp packet checksum }
  199.            );
  200.         7: (
  201.             newcid:                        UInt16;                                { new connection id returned }
  202.            );
  203.     END;
  204.  
  205. CONST
  206.     uppADSPConnectionEventProcInfo = $0000B802; { Register PROCEDURE (4 bytes in A1); }
  207.     uppADSPCompletionProcInfo = $00009802; { Register PROCEDURE (4 bytes in A0); }
  208.  
  209. FUNCTION NewADSPConnectionEventProc(userRoutine: ADSPConnectionEventProcPtr): ADSPConnectionEventUPP;
  210.     {$IFC NOT GENERATINGCFM }
  211.     INLINE $2E9F;
  212.     {$ENDC}
  213.  
  214. FUNCTION NewADSPCompletionProc(userRoutine: ADSPCompletionProcPtr): ADSPCompletionUPP;
  215.     {$IFC NOT GENERATINGCFM }
  216.     INLINE $2E9F;
  217.     {$ENDC}
  218.  
  219. PROCEDURE CallADSPConnectionEventProc(sourceCCB: TPCCB; userRoutine: ADSPConnectionEventUPP);
  220.     {$IFC NOT GENERATINGCFM}
  221.     {To be implemented:  Glue to move parameters into registers.}
  222.     {$ENDC}
  223.  
  224. PROCEDURE CallADSPCompletionProc(thePBPtr: DSPPBPtr; userRoutine: ADSPCompletionUPP);
  225.     {$IFC NOT GENERATINGCFM}
  226.     {To be implemented:  Glue to move parameters into registers.}
  227.     {$ENDC}
  228.  
  229. {$ALIGN RESET}
  230. {$POP}
  231.  
  232. {$SETC UsingIncludes := ADSPIncludes}
  233.  
  234. {$ENDC} {__ADSP__}
  235.  
  236. {$IFC NOT UsingIncludes}
  237.  END.
  238. {$ENDC}
  239.